#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main(){
	int n;
	string s1,s2,s3,last;
	cin >> n;
	while(n--){
		cin >> s1;
		if(s1=="a"){
			cin >> s2 >> s3;
			cout <<s2<<"+"<<s3<<"="<<(stoi(s2)+stoi(s3))<<endl;
			s2+=s3+"+"+"="+to_string((stoi(s2)+stoi(s3)));
			cout << s2.size()<<endl;
			last = s1;
		}
		else if(s1=="c"){
			cin >> s2 >>s3;
			cout <<s2<<"*"<<s3<<"="<<(stoi(s2)*stoi(s3))<<endl;
			s2+=s3+"+"+"="+to_string((stoi(s2)*stoi(s3)));
			cout << s2.size()<<endl;
			last = s1;
		}
		else if(s1=="b"){
			cin >> s2 >> s3;
			cout <<s2<<"-"<<s3<<"="<<(stoi(s2)-stoi(s3))<<endl;
			s2+=s3+"-"+"="+to_string((stoi(s2)-stoi(s3)));
			cout << s2.size()<<endl;
			last = s1;
		}
		else {
			if(last=="a"){
			cin >> s2 ;
			cout <<s1<<"+"<<s2<<"="<<(stoi(s2)+stoi(s1))<<endl;
			s2+="+"+s1+"="+to_string(stoi(s2)+stoi(s1));
			cout << s2.size()<<endl;
		}
		else if(last=="c"){
			cin >> s2 ;
			cout <<s1<<"*"<<s2<<"="<<(stoi(s2)*stoi(s1))<<endl;
			s2+="+"+s1+"="+to_string(stoi(s2)*stoi(s1));
			cout << s2.size()<<endl;
		}
		else if(last=="b"){
			cin >> s2 ;
			cout <<s1<<"-"<<s2<<"="<<(stoi(s1)-stoi(s2))<<endl;
			s2+="+"+s1+"="+to_string(stoi(s1)-stoi(s2));
			cout << s2.size()<<endl;
		}
		}
	}
	return 0;
}
